# syntax = docker/dockerfile:experimental
FROM node:lts-slim as builder
WORKDIR /app
ARG CONFIGURATION=production
COPY package.json .
COPY package-lock.json .
RUN --mount=type=cache,target=node_modules,id=npm_module,sharing=locked \
    --mount=type=cache,target=/root/.npm,id=npm_cache,sharing=locked \
    npm install
COPY . .
RUN --mount=type=cache,target=node_modules,id=npm_module,sharing=locked \
    npm run build --configuration=${CONFIGURATION}

FROM caddy:alpine
COPY --from=builder /app/Caddyfile /etc/caddy/Caddyfile
COPY --from=builder /app/dist/* /var/www/html/
